package cn.bdqn.t354.service.impl;

import cn.bdqn.t354.mapper.OrdersMapper;
import cn.bdqn.t354.pojo.Orders;
import cn.bdqn.t354.service.OrdersService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Resource
    private OrdersMapper ordersMapper;


    @Override
    public IPage<Orders> getOrdersByPage(String custNo,
                                         Integer pageNo, Integer pageSize) {
        //组装分页条件
        Page<Orders> page=new Page<>(pageNo,pageSize);

        //组装过滤条件 动态sql
        QueryWrapper<Orders> qw=new QueryWrapper();
        qw.eq(custNo!=null&&!"".equals(custNo), "odr_customer",custNo);

        //调用分页方法
        IPage<Orders> ordersPager=ordersMapper.selectPage(page,qw);
        //返回分页对象
        return ordersPager;
    }

    @Override
    public Orders getOrders(Long id) {
        return ordersMapper.selectById(id);
    }
}
